levels(chocolate$frequency.eat.chocolate) <- c("many times a day", "many times a week", "never", "once a month", "once a week") chocolate$handle.lack.of.chocolate=as.factor(chocolate$handle.lack.of.chocolate) levels(chocolate$handle.lack.of.chocolate) <- c("absolutely", "pretty much", "sometimes", "almost never", "never") levels(chocolate$kind.chocolate) <- c("almond chocolate", "black chocolate", "cooking chocolate", "lined chocolate", "milk chocolate", "white chocolate") chocolate$buy.fair.chocolate=as.factor(chocolate$buy.fair.chocolate) levels(chocolate$buy.fair.chocolate) <- c("never", "rarely", "sometimes", "often", "always") chocolate$savoured.alone=as.factor(chocolate$savoured.alone) levels(chocolate$savoured.alone) <- c("disagree", "slightly disagree", "neither agree nor disagree", "slightly agree", "agree") chocolate$savoured.with.people=as.factor(chocolate$savoured.with.people) levels(chocolate$savoured.with.people) <- c("disagree", "slightly disagree", "neither agree nor disagree", "slightly agree", "agree") colnames(chocolate)[14]="keep.chocolate" colnames(chocolate)[15]="eaten.without.other.food" chocolate$eaten.without.other.food=as.factor(chocolate$eaten.without.other.food) levels(chocolate$eaten.without.other.food) <- c("disagree", "slightly disagree", "neither agree nor disagree", "slightly agree", "agree") colnames(chocolate)[16:23]=c("inspires.pleasure","inspires.weakness.for.sweet.things","inspires.relaxation","inspires.voluptuousness","inspires.guilt","inspires.escape","inspires.energy","inspires.comfort") summary(chocolate) library(FactoMineR) library(dynGraph) library(EnQuireR) #MCA chocolate.MCA<-chocolate[, c("frequency.buy.chocolate", "frequency.eat.chocolate", "handle.lack.of.chocolate", "kind.chocolate", "kind.brands", "buy.fair.chocolate", "Where", "When", "side.drink", "savoured.alone", "savoured.with.people", "keep.chocolate", "eaten.without.other.food", "sex", "age", "inspires.pleasure", "inspires.weakness.for.sweet.things", "inspires.relaxation", "inspires.voluptuousness", "inspires.guilt", "inspires.escape", "inspires.energy", "inspires.comfort", "Image.chocolate")] res<-MCA(chocolate.MCA, ncp=5, quali.sup=14:24, level.ventil=0.05, graph = FALSE) plot.MCA(res, axes=c(1, 2), col.ind="black", col.ind.sup="blue", col.var="darkred", col.quali.sup="darkgreen", label=c("ind", "ind.sup", "quali.sup", "var", "quanti.sup"), invisible=c("")) plot.MCA(res, axes=c(1, 2), choix="var", col.var="darkred", col.quali.sup="darkgreen", label=c("var", "quali.sup"), invisible=c("")) #Dimensions description dimdesc(res,axes=1:2) #Hierarchical Clustering res.hcpc<-HCPC(res) #dynGraph dynGraph(res) #EnQuireR res.enmca <- ENMCA(chocolate.MCA, quali.sup=14:24, level.ventil=0.05, report=TRUE)